package com.itcat.controller;

import com.itcat.common.CommonPage;
import com.itcat.common.CommonResult;
import com.itcat.mysql.param.OmsOrderParam;
import com.itcat.mysql.param.OmsOrderReturnApplyParam;
import com.itcat.mysql.pojo.OmsOrder;
import com.itcat.mysql.pojo.OmsOrderReturnApply;
import com.itcat.mysql.vo.OmsOrderReturnApplyVo;
import com.itcat.mysql.vo.OmsOrderVo;
import com.itcat.service.OmsOrderReturnApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {

    @Autowired
    private OmsOrderReturnApplyService omsOrderReturnApplyService;


    /**
     * 分页查询退货申请
     *
     * @return
     */
    @GetMapping("list")
    public CommonResult OrderReturnApply(OmsOrderReturnApplyParam omsOrderReturnApplyParam) {
        CommonPage<OmsOrderReturnApply> pageResult = omsOrderReturnApplyService.OrderReturnApply(omsOrderReturnApplyParam);
        return CommonResult.success(pageResult);
    }

    /**
     * 批量删除退货申请
     *
     * @return
     */
    @PostMapping("/delete")
    public CommonResult delete(Integer[] ids) {
        omsOrderReturnApplyService.delete(ids);
        return CommonResult.success(null);
    }

    /**
     * 查询退货申请详情
     *
     * @return
     */
    @GetMapping("/{id}")
    public CommonResult returnApplyDetail(@PathVariable Integer id) {
        OmsOrderReturnApplyVo vo = omsOrderReturnApplyService.returnApplyDetail(id);
        return CommonResult.success(vo);
    }

    /**
     * 确认退货申请,收货
     *
     * @return
     */
    @PostMapping("/update/status/{id}")
    public CommonResult updateStatus(@RequestBody OmsOrderReturnApply omsOrderReturnApply, @PathVariable Integer id) {
        omsOrderReturnApplyService.updateStatus(omsOrderReturnApply, id);
        return CommonResult.success(null);
    }

}
